import random
import string

from api.login import LoginApI


class TestLoginApi(object):
    def setup_class(self):
        self.login = LoginApI()
    # 随机小数
    def test01_xs(self):
        r=random.random()
        resp=self.login.get_verify_code(r)
        print(resp)
        assert 200==resp.status_code
    # 随机整数
    def test02_zs(self):
        r = random.randint(1,99999)
        resp = self.login.get_verify_code(r)
        print(resp)
        assert 200 == resp.status_code
        with open("verify.png","wb") as f:
            f.write(resp.content)
    # 为空
    def test03(self):
        resp=self.login.get_verify_code("")
        print(resp)
        assert 404 == resp.status_code

    # 随机字符串
    def test04_string(self):
        r="".join(random.sample(string.ascii_letters+string.digits,6))
        resp = self.login.get_verify_code(r)
        print(resp)
        assert 400 == resp.status_code